// run: $exec < input
#include <iostream>
#include <algorithm>

int const maxn = 200;
int n, a[maxn];

void gauss_elimination()
{
	int k = 0;
	for (int j = 1 << 30, i; j; j >>= 1) {
		for (i = k + 1;  i <= n; i++)
			if (a[i] & j) break;
		if (i == n + 1) continue;
		std::swap(a[++k], a[i]);
		for (i = 1; i <= n; i++)
			if (i != k && (a[i] & j))
				a[i] ^= a[k];
	}
	n = k;
}

int main()
{
	std::ios::sync_with_stdio(false);
	int T; std::cin >> T;
	while (T--) {
		std::cin >> n;
		for (int i = 1; i <= n; i++) std::cin >> a[i];
		gauss_elimination();
		int ans = 0;
		for(int i = 1; i <= n; i++)
			ans ^= a[i];
		std::cout << ans << '\n';
	}
}

